package com.luyuan.crm.sale.model;

import java.io.Serializable;

import com.luyuan.crm.product.model.Product;
import com.ruijie.foundation.bo.EntityObject;

public class OrderProduct extends EntityObject<Serializable> implements Comparable<OrderProduct> {

    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    /**
     * 对应的产品
     */
    private Product product;

    private String name;

    private String specification;

    /**
     * 对应的订单
     */
    private Order order;

    /**
     * 数量
     */
    private int count = 1;

    /**
     * 单价
     */
    private double price;

    /**
     * 是否是赠品
     */
    private boolean gift = false;

    /**
     * 小计
     */
    private double subTotal;

    /**
     * 兑换积分
     */
    private int exchangeIntegral = 0;

    /**
     * 赠送数据
     */
    private int gifts = 0;

    public Product getProduct() {
        return product;
    }

    public void setProduct(Product product) {
        this.product = product;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSpecification() {
        return specification;
    }

    public void setSpecification(String specification) {
        this.specification = specification;
    }

    public Order getOrder() {
        return order;
    }

    public void setOrder(Order order) {
        this.order = order;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public boolean isGift() {
        return gift;
    }

    public void setGift(boolean gift) {
        this.gift = gift;
    }

    public double getSubTotal() {
        return subTotal;
    }

    public void setSubTotal(double subTotal) {
        this.subTotal = subTotal;
    }

    public int getExchangeIntegral() {
        return exchangeIntegral;
    }

    public void setExchangeIntegral(int exchangeIntegral) {
        this.exchangeIntegral = exchangeIntegral;
    }

    @Override
    public int compareTo(OrderProduct o) {
        if (gift != o.gift) {
            return gift ? 1 : -1;
        }
        return (int) (subTotal - o.subTotal);
    }

    public int getGifts() {
        return gifts;
    }

    public void setGifts(int gifts) {
        this.gifts = gifts;
    }
}
